-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created debounce & throttle effects #27
Conversation
Codecov Report
@@ Coverage Diff @@
## master #27 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 6 6
Lines 116 134 +18
Branches 12 13 +1
=====================================
+ Hits 116 134 +18
Continue to review full report at Codecov.
|
Thanks for the PR. Have you taken a look at my proposal #2 for |
You're welcome. I had a look at #2 after I after I created this PR. I've prepared a
Use case: listening for typing in a search ahead box. I don't want the search to start immediately, I want to start the search when the user has finished typing. |
@rmc thanks for the reference, I believe that confirms my beliefs WRT I hear folks mentioning the search box as a use case for debounce, but personally that user experience bugs me since you won't see the results update while you're typing. The ideal experience IMHO would be to trigger a search after each space immediately (more likely to match when you have a phrase with complete words) and throttle searches while the user is typing other characters so they don't overload your API. Should we have both |
@okwolf I liked your suggestion for searching and was able to implement it with startSimpleSearch: event => fxIf([
[/[^\s]$/.test(event.target.value), debounce(500, 'search')], // last char is not whitespace
[/\s$/.test(event.target.value), action('search')], // last char is whitespace
[/^(?![\s\S])/.test(event.target.value), action('noop')] // had to add this for reasons I'll explain later
] I'd go for adding both As for the last line in my example: I was implementing your search experience, and noticed that whenever all the conditions in So I implemented a |
@rmc thanks for trying out my crazy harebrained scheme! I'm OK with adding both I believe you are using |
Not really attached to Should I attach the Good to know I wasn't abusing |
`Boolean` options are to be avoided. Can always be added back as a field on `props` if the need arises.
@rmc thanks for the simplification! I think we just need docs and this effect will be 💯. |
Docs are ready to go. Please have a look at them to make sure they're clear enough. |
I needed a debounce effect so I created one.
Closes #2.